package com.yunzheng.studyLeaveSystem.modules.response;

import com.yunzheng.studyLeaveSystem.modules.response.ResultCode;

public class ResponseWrapper {
    private String code;
    private String msg;
    private Object data;

    public ResponseWrapper() {
    }

    public ResponseWrapper(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseWrapper{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }

    /**
     * 成功而且得返回数据（包括查询请假记录、研学记录又或者是请假次数成功）
     * @param data 传入要返回的数据
     * @return 返回响应对象
     */
    public static ResponseWrapper Success(Object data){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.SUCCESS.getCode());
        responseWrapper.setMsg(ResultCode.SUCCESS.getMsg());
        responseWrapper.setData(data);
        return responseWrapper;
    }

    /**
     * 成功但没数据可返回（注册成功，登录成功，请假成功，调研学成功，修改成功）
     * @return 返回响应对象
     */
    public static ResponseWrapper SuccessButNoData(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.NODATA.getCode());
        responseWrapper.setMsg(ResultCode.NODATA.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 失败（暂时包括各种失败）
     * @return 返回响应对象
     */
    public static ResponseWrapper Error(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.FAILURE.getCode());
        responseWrapper.setMsg(ResultCode.FAILURE.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 不存在该用户
     * @return 返回响应对象
     */
    public static ResponseWrapper ACCOUNT_FAILURE(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.ACCOUNT_FAILURE.getCode());
        responseWrapper.setMsg(ResultCode.ACCOUNT_FAILURE.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 用户名与密码不匹配
     * @return 返回响应对象
     */
    public static ResponseWrapper PWD_FAILURE(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.PWD_FAILURE.getCode());
        responseWrapper.setMsg(ResultCode.PWD_FAILURE.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 该用户已存在，无法注册
     * @return 返回响应对象
     */
    public static ResponseWrapper EXIST_FAILURE(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.EXIST_FAILURE.getCode());
        responseWrapper.setMsg(ResultCode.EXIST_FAILURE.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 云顶系统不存在该同学，无法注册
     * @return 返回响应对象
     */
    public static ResponseWrapper MEMBER_FAILURE(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.MEMBER_FAILURE.getCode());
        responseWrapper.setMsg(ResultCode.MEMBER_FAILURE.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 邀请码错误，无法注册
     * @return 返回响应对象
     */
    public static ResponseWrapper INVITE_FAILURE(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.INVITE_FAILURE.getCode());
        responseWrapper.setMsg(ResultCode.INVITE_FAILURE.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    public static ResponseWrapper USER_SUCCESS(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.USER_SUCCESS.getCode());
        responseWrapper.setMsg(ResultCode.USER_SUCCESS.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    public static ResponseWrapper ADMIN_SUCCESS(){
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.ADMIN_SUCCESS.getCode());
        responseWrapper.setMsg(ResultCode.ADMIN_SUCCESS.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }
    /**
     * 修改密码失败(原密码输错)
     *
     * @return 返回响应对象
     */
    public static ResponseWrapper Error1() {
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.FAILURE1.getCode());
        responseWrapper.setMsg(ResultCode.FAILURE1.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 修改密码失败(修改密码不一致)
     *
     * @return 返回响应对象
     */
    public static ResponseWrapper Error2() {
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.FAILURE2.getCode());
        responseWrapper.setMsg(ResultCode.FAILURE2.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 修改手机号失败(原手机号输错)
     * @return
     */
    public static ResponseWrapper Error3 () {
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.FAILURE3.getCode());
        responseWrapper.setMsg(ResultCode.FAILURE3.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }

    /**
     * 修改手机号失败(修改手机号不一致)
     * @return
     */
    public static ResponseWrapper Error4 () {
        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.setCode(ResultCode.FAILURE4.getCode());
        responseWrapper.setMsg(ResultCode.FAILURE4.getMsg());
        responseWrapper.setData(null);
        return responseWrapper;
    }
}

